/*
 * @Author: your name
 * @Date: 2021-04-23 23:32:50
 * @LastEditTime: 2021-04-24 07:31:20
 * @LastEditors: your name
 * @Description: In User Settings Edit
 * @FilePath: \offer20k\项目代码\fantasticit\src\store\modules\homepage.ts
 */
import { makeAutoObservable } from "mobx"
import { gitarticlerecommend, getshow, page, getkeyword } from "@/services/homepageapi"
import { articleRecommend, show, search } from "@/util/homepage"
class Homepage {
    constructor() {
        makeAutoObservable(this);
        // gitarticlerecommend()
    }
    a: string = "首页"
    articleRecommend: articleRecommend[] = []
    showlist: show[] = []
    searchlist: search[] = []
    page = 1
    flag = false
    footer = true

    async gitarticlerecommend() {
        let recommend = await gitarticlerecommend()
        if (recommend.statusCode === 200) {
            this.articleRecommend = recommend.data
        }
    }
    async pages() {
        let recommend = await page(this.page)
        this.page++
        // debugger
        if (recommend.statusCode === 200) {
            recommend.data[0].map((i: any) => {
                this.articleRecommend.push(i)
            })


        }
    }

    async gitshow() {
        let show = await getshow()
        if (show.statusCode === 200) {
            this.showlist = show.data
        }
    }


    async setfalg() {
        this.flag = !this.flag
    }
    async setfooter(falg: boolean) {
        this.footer = falg
    }
    async getfilter(key: string) {
        let list = await getkeyword(key)
        if (list.statusCode === 200) {
            this.searchlist = list.data
        }
    }
}

export default Homepage;